| Conditions | 5 |
| Total Lines | 51 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | var table; |
||
| 24 | function loadDT() { |
||
| 25 | table = $("#list").DataTable({ |
||
| 26 | destroy: true, |
||
| 27 | //dom: "Bfrtip", |
||
| 28 | processing: false, |
||
| 29 | serverSide: false, |
||
| 30 | stateSave: false, |
||
| 31 | autoWidth: false, |
||
| 32 | responsive: true, |
||
| 33 | deferRender: true, |
||
| 34 | paging: true, |
||
| 35 | lengthMenu: [5, 10, 15, 20, 25, 30, 100, 200, 300, 400, 500, "All"], |
||
| 36 | ajax: { |
||
| 37 | url: "list", |
||
| 38 | method: "POST", |
||
| 39 | data: { |
||
| 40 | "list-user": guid(), |
||
| 41 | }, |
||
| 42 | dataSrc: function (res) { |
||
| 43 | console.log(res); |
||
|
|
|||
| 44 | |||
| 45 | return res; |
||
| 46 | }, |
||
| 47 | }, |
||
| 48 | columns: [ |
||
| 49 | { |
||
| 50 | title: "username", |
||
| 51 | data: "username", |
||
| 52 | }, |
||
| 53 | { |
||
| 54 | title: "name", |
||
| 55 | data: "display_name", |
||
| 56 | }, |
||
| 57 | { |
||
| 58 | title: "email", |
||
| 59 | data: "email", |
||
| 60 | }, |
||
| 61 | { |
||
| 62 | title: "Role", |
||
| 63 | data: "role", |
||
| 64 | }, |
||
| 65 | { |
||
| 66 | title: "Last seen", |
||
| 67 | data: "last_seen", |
||
| 68 | }, |
||
| 69 | ], |
||
| 70 | }); |
||
| 71 | table.on("init.dt", function () { |
||
| 72 | $(this).removeClass("table-loader").show(); |
||
| 73 | }); |
||
| 74 | } |
||
| 75 |